import numpy as np

a = np.array([[1, 2], [3, 4], [5, 6]])
print(a[[0, 1, 2]])
# [[1 2]
#  [3 4]
#  [5 6]]
print(a[[0, 1, 2], [0, 1, 0]])
# [1 4 5]
print(np.array([a[0, 0], a[1, 1], a[2, 0]]))
# [1 4 5]
print(a[[0, 0], [1, 1]])
print(np.array([a[0, 1], a[0, 1]]))
# [2 2]
# [2 2]


a = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]])
b = np.array([0, 2, 0, 1])
print(a[np.arange(4), b])
a[np.arange(4), b] += 10
print(a)
# [ 1  6  7 11]
# [[11  2  3]
#  [ 4  5 16]
#  [17  8  9]
#  [10 21 12]]


a = np.array([[1, 2], [3, 4], [5, 6]])
bool_idx = (a > 2)
print(bool_idx)
print(a[bool_idx])
print(a[a > 2])
# [[False False]
#  [ True  True]
#  [ True  True]]
# [3 4 5 6]
# [3 4 5 6]

x = np.array([[1, 2], [3, 4]])
print(x)
print(x.T)
# [[1 2]
#  [3 4]]
# [[1 3]
#  [2 4]]
